﻿#include "service.h"

int UserTank::move(Direction dir, int map[26][26]) {
	int new_x = this->pos_x;
	int new_y = this->pos_y;
	if (dir == Up) {
		new_x--;
		if ((map[new_x][new_y] == 3 || map[new_x][new_y] == 0) && new_x >= 0) {
			return 1;
		}
	}
	else if (dir == Down) {
		new_x++;
		if ((map[new_x][new_y] == 3 || map[new_x][new_y] == 0) && new_x < 26) {
			return 1;
		}
	}
	else if (dir == Left) {
		new_y--;
		if ((map[new_x][new_y] == 3 || map[new_x][new_y] == 0) && new_y >= 0) {
			return 1;
		}
	}
	else if (dir == Right) {
		new_y++;
		if ((map[new_x][new_y] == 3 || map[new_x][new_y] == 0) && new_y < 26) {
			return 1;
		}
	}
	//无效操作返回空值
	return 0;
}

UserTank::UserTank(int l, int b, int s, Direction d, int x, int y) {
	this->life = l; this->bullet = b; this->speed = s;
	this->dir = d; this->pos_x = x; this->pos_y = y;
}

int Bullets::move(int map[26][26]) {
	int dx[] = { 1, -1, 0, 0 }, dy[] = { 0, 0, 1, -1 };
	int new_x = this->pos_x + dx[this->dir], new_y = this->pos_y + dy[this->dir];
	this->pos_x = new_x;
	this->pos_y = new_y;
	if (map[new_x][new_y] == 1) {
		return 1;  // 墙壁返回1
	}
	else if (map[new_x][new_y] == 2) {
		if (true/*判断是否击破条件未知*/)
			return 2;// 钢板返回2（不击破）
		else
			return 3;// 击破钢板 返回 3
	}
	else if (map[new_x][new_y] == 7) {
		return 4;  //坦克返回4
	}
	else
		return 0;
}

void Init(int &Level, int map[26][26]) {
	InputMap(Level, map);
}

Direction ShiftDirection() {
	char UserInput;
	if (_kbhit()) {
		UserInput = _getch();
		switch (UserInput) {
		case 'w':		//上
			return Up;
			break;
		case 's':		//下
			return Down;
			break;
		case 'a':		//左
			return Left;
			break;
		case 'd':		//右
			return Right;
			break;
		default:
			break;
		}
	}
	return Null;
}

//判断用户输入是否有效，若有效则生成炮弹
bool BulletCreat(char UserInput) {
	char in = UserInput;
	if (in == 'j' || in == 'J' || in == 'p' || in == 'P')
		return true;
	return false;
}

bool EnemyCreat(int Time) {
	return false;
}

EnemyTank::EnemyTank(Direction dir, int x, int y) {
	this->dir = dir;
	this->pos_x = x;
	this->pos_y = y;
}

int EnemyTank::move(Direction &dir, int map[26][26]) {
	return 0;
}
// 定位转换
int  pointswitch(UserTank *tank, Direction dirction) {
	if (tank->dir == Down) {
		if (dirction == Left) {
			tank->pos_y -= 1;
		}
		else if (dirction == Up) {
			tank->pos_x -= 1;
			tank->pos_y -= 1;
		}
		else if (dirction == Right) {
			tank->pos_x -= 1;
		}
		return 0;
	}
	else if (tank->dir == Left) {
		if (dirction == Up) {
			tank->pos_x -= 1;
		}
		else if (dirction == Right) {
			tank->pos_x -= 1;
			tank->pos_y += 1;
		}
		else if (dirction == Down) {
			tank->pos_y += 1;
		}
		return 0;
	}
	else if (tank->dir == Right) {
		if (dirction == Down) {
			tank->pos_x += 1;
		}
		else if (dirction == Left) {
			tank->pos_x += 1;
			tank->pos_y -= 1;
		}
		else if (dirction == Up) {
			tank->pos_y -= 1;
		}
		return 0;
	}
	else if (tank->dir == Up) {
		if (dirction == Right) {
			tank->pos_y += 1;
		}
		else if (dirction == Down) {
			tank->pos_x += 1;
			tank->pos_y += 1;
		}
		else if (dirction == Left) {
			tank->pos_x += 1;
		}
		return 0;
	}
	return 0;
}

//移动
void move(UserTank *tank, Direction dirction, IMAGE *img, int step) {
	setfillcolor(BLACK);
	//向前移动
	if (step == 1) {
		if (dirction == Down) {

			solidrectangle((tank->pos_y - 1) * 25 + 100, (tank->pos_x - 1) * 25, (tank->pos_y - 1) * 25 + 50 + 100, (tank->pos_x - 1) * 25 + 25);
			putimage((tank->pos_y - 1) * 25 + 100, (tank->pos_x - 1) * 25 + 25, img);
		}
		else if (dirction == Left) {
			solidrectangle((tank->pos_y) * 25 - 25 + 25 + 100, (tank->pos_x - 1) * 25, (tank->pos_y) * 25 - 25 + 25 + 50 + 100, (tank->pos_x - 1) * 25 + 50);
			putimage((tank->pos_y) * 25 - 25 + 100, (tank->pos_x - 1) * 25, img);
		}
		else if (dirction == Up) {
			solidrectangle((tank->pos_y) * 25 + 100, (tank->pos_x) * 25 + 25 - 25, (tank->pos_y) * 25 + 50 + 100, (tank->pos_x) * 25 - 25 + 25 + 50);
			putimage((tank->pos_y) * 25 + 100, (tank->pos_x) * 25 - 25, img);
		}
		else if (dirction == Right) {
			solidrectangle((tank->pos_y - 1) * 25 - 25 + 25 + 100, (tank->pos_x) * 25, (tank->pos_y - 1) * 25 + 25 - 25 + 50 + 100, (tank->pos_x) * 25 + 50);
			putimage((tank->pos_y - 1) * 25 + 25 + 100, (tank->pos_x) * 25, img);
		}
	}
	//转向
	else if (step == 0) {
		if (dirction == Down) {
			putimage((tank->pos_y - 1) * 25 + 100, (tank->pos_x - 1) * 25, img);
		}
		else if (dirction == Left) {
			putimage((tank->pos_y) * 25 + 100, (tank->pos_x - 1) * 25, img);
		}
		else if (dirction == Up) {
			putimage((tank->pos_y) * 25 + 100, (tank->pos_x) * 25, img);
		}
		else if (dirction == Right) {
			putimage((tank->pos_y - 1) * 25 + 100, (tank->pos_x) * 25, img);
		}
	}
}
// 敌方坦克定位转换
int  pointswitch_e(EnemyTank *tank, Direction dirction) {
	if (tank->dir == Down) {
		if (dirction == Left) {
			tank->pos_y -= 1;
		}
		else if (dirction == Up) {
			tank->pos_x -= 1;
			tank->pos_y -= 1;
		}
		else if (dirction == Right) {
			tank->pos_x -= 1;
		}
		return 0;
	}
	else if (tank->dir == Left) {
		if (dirction == Up) {
			tank->pos_x -= 1;
		}
		else if (dirction == Right) {
			tank->pos_x -= 1;
			tank->pos_y += 1;
		}
		else if (dirction == Down) {
			tank->pos_y += 1;
		}
		return 0;
	}
	else if (tank->dir == Right) {
		if (dirction == Down) {
			tank->pos_x += 1;
		}
		else if (dirction == Left) {
			tank->pos_x += 1;
			tank->pos_y -= 1;
		}
		else if (dirction == Up) {
			tank->pos_y -= 1;
		}
		return 0;
	}
	else if (tank->dir == Up) {
		if (dirction == Right) {
			tank->pos_y += 1;
		}
		else if (dirction == Down) {
			tank->pos_x += 1;
			tank->pos_y += 1;
		}
		else if (dirction == Left) {
			tank->pos_x += 1;
		}
		return 0;
	}
	return 0;
}
//敌方移动
void move_e(EnemyTank *tank, Direction dirction, IMAGE *img, int step) {
	setfillcolor(BLACK);
	//向前移动
	if (step == 1) {
		if (dirction == Down) {

			solidrectangle((tank->pos_y - 1) * 25 + 100, (tank->pos_x - 1) * 25, (tank->pos_y - 1) * 25 + 50 + 100, (tank->pos_x - 1) * 25 + 25);
			putimage((tank->pos_y - 1) * 25 + 100, (tank->pos_x - 1) * 25 + 25, img);
			tank->pixel_x = (tank->pos_y - 1) * 25 + 100;
			tank->pixel_y = (tank->pos_x - 1) * 25 + 25;
		}
		else if (dirction == Left) {
			solidrectangle((tank->pos_y) * 25 - 25 + 25 + 100, (tank->pos_x - 1) * 25, (tank->pos_y) * 25 - 25 + 25 + 50 + 100, (tank->pos_x - 1) * 25 + 50);
			putimage((tank->pos_y) * 25 - 25 + 100, (tank->pos_x - 1) * 25, img);
			tank->pixel_x = (tank->pos_y) * 25 - 25 + 100;
			tank->pixel_y = (tank->pos_x - 1) * 25;
		}
		else if (dirction == Up) {
			solidrectangle((tank->pos_y) * 25 + 100, (tank->pos_x) * 25 + 25 - 25, (tank->pos_y) * 25 + 50 + 100, (tank->pos_x) * 25 - 25 + 25 + 50);
			putimage((tank->pos_y) * 25 + 100, (tank->pos_x) * 25 - 25, img);
			tank->pixel_x = (tank->pos_y) * 25 + 100;
			tank->pixel_y = (tank->pos_x) * 25 - 25;
		}
		else if (dirction == Right) {
			solidrectangle((tank->pos_y - 1) * 25 - 25 + 25 + 100, (tank->pos_x) * 25, (tank->pos_y - 1) * 25 + 25 - 25 + 50 + 100, (tank->pos_x) * 25 + 50);
			putimage((tank->pos_y - 1) * 25 + 25 + 100, (tank->pos_x) * 25, img);
			tank->pixel_x = (tank->pos_y - 1) * 25 + 25 + 100;
			tank->pixel_y = (tank->pos_x) * 25;
		}
	}
	//转向
	else if (step == 0) {
		if (dirction == Down) {
			putimage((tank->pos_y - 1) * 25 + 100, (tank->pos_x - 1) * 25, img);
		}
		else if (dirction == Left) {
			putimage((tank->pos_y) * 25 + 100, (tank->pos_x - 1) * 25, img);
		}
		else if (dirction == Up) {
			putimage((tank->pos_y) * 25 + 100, (tank->pos_x) * 25, img);
		}
		else if (dirction == Right) {
			putimage((tank->pos_y - 1) * 25 + 100, (tank->pos_x) * 25, img);
		}
	}
}
//开火
int shoot(Bullet *bullet, int map[26][26], int i, UserTank *tank, EnemyTank *tank_e) {
	//我方坦克开火
	if (i == 0) {
		//消除上一次生成的子弹
		setfillcolor(BLACK);
		solidrectangle(bullet->pos_y, bullet->pos_x, bullet->pos_y + 4, bullet->pos_x + 4);
		//计算此次子弹坐标
		if (bullet->dir == Up) {
			bullet->pos_x -= 4;
		}
		else if (bullet->dir == Down) {
			bullet->pos_x += 4;
		}
		else if (bullet->dir == Left) {
			bullet->pos_y -= 4;
		}
		else if (bullet->dir == Right) {
			bullet->pos_y += 4;
		}
		//判断是否出界
		if (bullet->pos_x >= 650 || bullet->pos_x <= 0 || bullet->pos_y <= 100 || bullet->pos_y >= 750) {
			bullet->status = 0;
			return 0;
		}
		//判断是否撞击铁墙
		if ((map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25] == 2 || map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25 + 1] == 2) && bullet->dir == Down) {
			bullet->status = 0;
			return 0;
		}
		else if ((map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25] == 2 || map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25 + 1] == 2) && bullet->dir == Up) {
			bullet->status = 0;
			return 0;
		}
		else if ((map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25] == 2 || map[(bullet->pos_x + 4) / 25 - 1][(bullet->pos_y - 100) / 25] == 2) && bullet->dir == Right) {
			bullet->status = 0;
			return 0;
		}
		else if ((map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25] == 2 || map[(bullet->pos_x + 4) / 25 - 1][(bullet->pos_y - 100) / 25] == 2) && bullet->dir == Left) {
			bullet->status = 0;
			return 0;
		}
		//判断是否撞击普通墙
		setfillcolor(BLACK);
		if ((map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25] == 1 || map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25 + 1] == 1) && bullet->dir == Down) {
			solidrectangle(((bullet->pos_y - 100) / 25) * 25 + 100, ((bullet->pos_x + 4) / 25) * 25, ((bullet->pos_y - 100) / 25) * 25 + 25 + 100 + 25, ((bullet->pos_x + 4) / 25) * 25 + 25);
			if (map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25] == 1) {
				map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25] = 0;
			}
			if (map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25 + 1] == 1) {
				map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25 + 1] = 0;
			}
			bullet->status = 0;
			return 0;
		}
		else if ((map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25] == 1 || map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25 + 1] == 1) && bullet->dir == Up) {
			solidrectangle(((bullet->pos_y - 100) / 25) * 25 + 100, ((bullet->pos_x + 4) / 25) * 25, ((bullet->pos_y - 100) / 25) * 25 + 25 + 100 + 25, ((bullet->pos_x + 4) / 25) * 25 + 25);
			if (map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25] == 1) {
				map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25] = 0;
			}
			if (map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25 + 1] == 1) {
				map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25 + 1] = 0;
			}
			bullet->status = 0;
			return 0;
		}
		else if ((map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25] == 1 || map[(bullet->pos_x + 4) / 25 - 1][(bullet->pos_y - 100) / 25] == 1) && bullet->dir == Right) {
			solidrectangle(((bullet->pos_y - 100) / 25) * 25 + 100, ((bullet->pos_x + 4) / 25) * 25 - 25, ((bullet->pos_y - 100) / 25) * 25 + 25 + 100, ((bullet->pos_x + 4) / 25) * 25 + 25);
			if (map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25] == 1) {
				map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25] = 0;
			}
			if (map[(bullet->pos_x + 4) / 25 - 1][(bullet->pos_y - 100) / 25] == 1) {
				map[(bullet->pos_x + 4) / 25 - 1][(bullet->pos_y - 100) / 25] = 0;
			}
			bullet->status = 0;
			return 0;
		}
		else if ((map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25] == 1 || map[(bullet->pos_x + 4) / 25 - 1][(bullet->pos_y - 100) / 25] == 1) && bullet->dir == Left) {
			solidrectangle(((bullet->pos_y - 100) / 25) * 25 + 100, ((bullet->pos_x + 4) / 25) * 25 - 25, ((bullet->pos_y - 100) / 25) * 25 + 25 + 100, ((bullet->pos_x + 4) / 25) * 25 + 25);
			if (map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25] == 1) {
				map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25] = 0;
			}
			if (map[(bullet->pos_x + 4) / 25 - 1][(bullet->pos_y - 100) / 25] == 1) {
				map[(bullet->pos_x + 4) / 25 - 1][(bullet->pos_y - 100) / 25] = 0;
			}
			bullet->status = 0;
			return 0;
		}
		//绘制子弹
		setfillcolor(WHITE);
		solidrectangle(bullet->pos_y, bullet->pos_x, bullet->pos_y + 4, bullet->pos_x + 4);
		//摧毁家
		if (bullet->pos_y + 3 > 400 && bullet->pos_y - 3 < 450 && bullet->pos_x + 6 > 600 && bullet->pos_x - 6 < 650)
			return -1;
		//摧毁敌方坦克
		if (bullet->pos_y + 3 > tank_e->pixel_x && bullet->pos_y - 3 < tank_e->pixel_x + 50 && bullet->pos_x + 6 > tank_e->pixel_y && bullet->pos_x - 6 < tank_e->pixel_y + 50) {
			return 1;
		}
	}
	//敌方坦克开火
	if (i == 1) {
		//消除上一次生成的子弹
		setfillcolor(BLACK);
		solidrectangle(bullet->pos_y, bullet->pos_x, bullet->pos_y + 4, bullet->pos_x + 4);
		//计算此次子弹坐标
		if (bullet->dir == Up) {
			bullet->pos_x -= 4;
		}
		else if (bullet->dir == Down) {
			bullet->pos_x += 4;
		}
		else if (bullet->dir == Left) {
			bullet->pos_y -= 4;
		}
		else if (bullet->dir == Right) {
			bullet->pos_y += 4;
		}
		//判断是否出界
		if (bullet->pos_x >= 650 || bullet->pos_x <= 0 || bullet->pos_y <= 100 || bullet->pos_y >= 750) {
			bullet->status = 0;
			return 0;
		}
		//判断是否撞击铁墙
		if ((map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25] == 2 || map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25 + 1] == 2) && bullet->dir == Down) {
			bullet->status = 0;
			return 0;
		}
		else if ((map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25] == 2 || map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25 + 1] == 2) && bullet->dir == Up) {
			bullet->status = 0;
			return 0;
		}
		else if ((map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25] == 2 || map[(bullet->pos_x + 4) / 25 - 1][(bullet->pos_y - 100) / 25] == 2) && bullet->dir == Right) {
			bullet->status = 0;
			return 0;
		}
		else if ((map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25] == 2 || map[(bullet->pos_x + 4) / 25 - 1][(bullet->pos_y - 100) / 25] == 2) && bullet->dir == Left) {
			bullet->status = 0;
			return 0;
		}
		//判断是否撞击普通墙
		setfillcolor(BLACK);
		if ((map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25] == 1 || map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25 + 1] == 1) && bullet->dir == Down) {
			solidrectangle(((bullet->pos_y - 100) / 25) * 25 + 100, ((bullet->pos_x + 4) / 25) * 25, ((bullet->pos_y - 100) / 25) * 25 + 25 + 100 + 25, ((bullet->pos_x + 4) / 25) * 25 + 25);
			if (map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25] == 1) {
				map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25] = 0;
			}
			if (map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25 + 1] == 1) {
				map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25 + 1] = 0;
			}
			bullet->status = 0;
			return 0;
		}
		else if ((map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25] == 1 || map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25 + 1] == 1) && bullet->dir == Up) {
			solidrectangle(((bullet->pos_y - 100) / 25) * 25 + 100, ((bullet->pos_x + 4) / 25) * 25, ((bullet->pos_y - 100) / 25) * 25 + 25 + 100 + 25, ((bullet->pos_x + 4) / 25) * 25 + 25);
			if (map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25] == 1) {
				map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25] = 0;
			}
			if (map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25 + 1] == 1) {
				map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25 + 1] = 0;
			}
			bullet->status = 0;
			return 0;
		}
		else if ((map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25] == 1 || map[(bullet->pos_x + 4) / 25 - 1][(bullet->pos_y - 100) / 25] == 1) && bullet->dir == Right) {
			solidrectangle(((bullet->pos_y - 100) / 25) * 25 + 100, ((bullet->pos_x + 4) / 25) * 25 - 25, ((bullet->pos_y - 100) / 25) * 25 + 25 + 100, ((bullet->pos_x + 4) / 25) * 25 + 25);
			if (map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25] == 1) {
				map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25] = 0;
			}
			if (map[(bullet->pos_x + 4) / 25 - 1][(bullet->pos_y - 100) / 25] == 1) {
				map[(bullet->pos_x + 4) / 25 - 1][(bullet->pos_y - 100) / 25] = 0;
			}
			bullet->status = 0;
			return 0;
		}
		else if ((map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25] == 1 || map[(bullet->pos_x + 4) / 25 - 1][(bullet->pos_y - 100) / 25] == 1) && bullet->dir == Left) {
			solidrectangle(((bullet->pos_y - 100) / 25) * 25 + 100, ((bullet->pos_x + 4) / 25) * 25 - 25, ((bullet->pos_y - 100) / 25) * 25 + 25 + 100, ((bullet->pos_x + 4) / 25) * 25 + 25);
			if (map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25] == 1) {
				map[(bullet->pos_x + 4) / 25][(bullet->pos_y - 100) / 25] = 0;
			}
			if (map[(bullet->pos_x + 4) / 25 - 1][(bullet->pos_y - 100) / 25] == 1) {
				map[(bullet->pos_x + 4) / 25 - 1][(bullet->pos_y - 100) / 25] = 0;
			}
			bullet->status = 0;
			return 0;
		}
		//绘制子弹
		setfillcolor(WHITE);
		solidrectangle(bullet->pos_y, bullet->pos_x, bullet->pos_y + 4, bullet->pos_x + 4);
		//摧毁家
		if (bullet->pos_y + 3 > 400 && bullet->pos_y - 3 < 450 && bullet->pos_x + 6 > 600 && bullet->pos_x - 6 < 650)
			return -1;
		//摧毁我方坦克
		if (bullet->pos_y + 3 > tank->pixel_x && bullet->pos_y - 3 < tank->pixel_x + 50 && bullet->pos_x + 6 > tank->pixel_y && bullet->pos_x - 6 < tank->pixel_y + 50) {
			return -1;
		}
	}
	return 0;
}
//自动选择路径
char automatic(EnemyTank *tank) {
	srand((unsigned)time(NULL));
	int num;
	num = rand() % 7 + 1;
	//开火
	if (num % 2 == 0) {
		return 'p';
	}
	//上
	else if (num == 1) {
		return 'w';
	}
	//下
	else if (num == 3) {
		return 's';
	}
	//左
	else if (num == 5) {
		return 'a';
	}
	//右
	else if (num == 7) {
		return'd';
	}
	return ' ';
}